package com.zhongzhi.controller;


import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.zhongzhi.service.StationService;
import com.fasterxml.jackson.core.json.JsonReadContext;
import com.zhongzhi.service.EquipmentService;
import com.zhongzhi.springboot.pojo.Computers;
import com.zhongzhi.springboot.pojo.Equipment;
import com.zhongzhi.util.Bo;
import com.zhongzhi.util.JsonResult;

import lombok.extern.log4j.Log4j;
/**
 * 设备业务层
 * @author Administrator
 *
 */
@RestController
@RequestMapping("/equipment/")
public class EquipmentController {

	@Autowired
	private EquipmentService equipmentService;
	//1:增加设备
	@RequestMapping("insert")
	public JsonResult insert(Equipment equipment) {
		Bo bo = equipmentService.insert(equipment);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//2:修改设备
	@RequestMapping("update")
	public JsonResult update(Equipment equipment) {
		Bo bo = equipmentService.update(equipment);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}

	//3:删除设备(如果设备有者通道,则不能删除)
	@RequestMapping("delete")
	public JsonResult delete(Integer id) {
		Bo bo = equipmentService.delete(id);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//4:查询全部设备
	@RequestMapping("select")
	public JsonResult select(Integer pages,Integer line) {
		Bo bo = equipmentService.select(pages,line);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}

	//5:查询全部设备总数
	@RequestMapping("selectSize")
	public JsonResult selectSize() {
		Bo bo = equipmentService.selectSize();
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//6:查询设备(根据id查询)
	@RequestMapping("selectById")
	public JsonResult selectById(Integer id) {
		Bo bo = equipmentService.selectById(id);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}

	//7:根据计算机id集合查询
	@RequestMapping("selectByIds")
	public JsonResult selectByIds(Integer[] ids) {
		Bo bo = equipmentService.selectByIds(ids);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//8:增加计算机
	@RequestMapping("webinsert")
	public JsonResult webinsert(Equipment equipment) {
		Bo bo = equipmentService.webinsert(equipment);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//9:修改计算机
	@RequestMapping("webupdate")
	public JsonResult webupdate(Equipment equipment) {
		Bo bo = equipmentService.webupdate(equipment);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}

	//10:删除计算机(如果计算机有者通道,则不能删除)
	@RequestMapping("webdelete")
	public JsonResult webdelete(Integer id) {
		Bo bo = equipmentService.webdelete(id);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//11:查询全部计算机
	@RequestMapping("webselect")
	public JsonResult webselect() {
		Bo bo = equipmentService.webselect();
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
}
